package com.lh0811.forge.pserv.uacs.server.component.real_name_auth;

import com.lh0811.forge.dependency.security.client.component.annotation.AuthAbstractClass;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author lh0811
 * @date 2021/5/10
 */
@Aspect
@Slf4j
@Component
public class CheckUserRealNameAop extends AuthAbstractClass {

    @Resource
    private UserRealNameCheckHandler userRealNameCheckHandler;

    @Pointcut("@within(com.lh0811.forge.pserv.uacs.api.component.real_name_auth.CheckUserRealName) || @annotation(com.lh0811.forge.pserv.uacs.api.component.real_name_auth.CheckUserRealName)")
    public void annotationPointCut() {
    }


    @Around("annotationPointCut()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        log.debug("进入CheckUserRealNameAop切面");
        // 校验用户是否实名认证
        userRealNameCheckHandler.check();
        Object proceed = joinPoint.proceed(joinPoint.getArgs());
        log.debug("退出CheckUserRealNameAop切面");
        return proceed;
    }

}
